home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / database / dg53.zip / DGW.BAT < prev    next >
DOS Batch File  |  1997-03-15  |  2KB  |  68 lines

  1. @ECHO OFF
  2. rem bat file to use dg with wildcarded list-of-files-to-search
  3. rem usage dgw -dg_arguments searchterm [*.txt or ad.* etc.] 
  4. rem note: a dg argument must be given, at least -o (a do-nothing)
  5. rem note: always writes result to file named ztempx (and sends to more)
  6. rem note: thus ztempx must not be in the scope of the wildcard
  7.  
  8. IF "%1" == "" GOTO helps
  9. IF "%3" == "" GOTO error
  10. ECHO ======Executing the command dg %1 %2 %3 %4 %5 %6
  11. ECHO ======Will overwrite ztempx
  12. ECHO ======RETURN to continue, ctrl-C to quit
  13. PAUSE
  14. IF EXIST ztempx  DEL ztempx>NUL
  15. rem if touch program not available, use: @REM redirect_to ztempx
  16. rem touch ztempx
  17. @REM >ztempx
  18.  
  19. rem current setup for 6 total args: supports, e.g., up to -m3
  20. rem its possible to send 11 arguments with, e.g., -m9
  21. rem expand below to handle 11 if desired
  22. if exist %6 goto six
  23. if exist %5 goto five
  24. if exist %4 goto four
  25. if exist %3 goto three
  26.  
  27. :six
  28. FOR %%X IN (%6) do if %%X==ZTEMPX goto scope
  29. FOR %%X IN (%6) DO COMMAND/C dg %1 %2 %3 %4 %5 %%X >> ztempx
  30. goto didsearch
  31. :five
  32. FOR %%X IN (%5) do if %%X==ZTEMPX goto scope
  33. FOR %%X IN (%5) DO COMMAND/C dg %1 %2 %3 %4 %%X >> ztempx
  34. goto didsearch
  35. :four
  36. FOR %%X IN (%4) do if %%X==ZTEMPX goto scope
  37. FOR %%X IN (%4) DO COMMAND/C dg %1 %2 %3 %%X >> ztempx
  38. goto didsearch
  39. :three
  40. FOR %%X IN (%3) do if %%X==ZTEMPX goto scope
  41. FOR %%X IN (%3) DO COMMAND/C dg %1 %2 %%X >> ztempx
  42. goto didsearch
  43.  
  44. :didsearch
  45.  
  46. echo ================ FINDS: ===================================
  47. TYPE ztempx | more
  48. ECHO =========== Finds placed in file ztempx ===================
  49. GOTO end
  50. :scope
  51. echo ERROR- the wildcard term includes the output file "ztempx"
  52. goto paterror
  53. :error
  54. ECHO   dgw error.
  55. :helps
  56. ECHO   dgw is used to do a dg-search against a wildcard list-of-files.
  57. ECHO   e.g. " dgw -Kp searchterm *.foo " 
  58. ECHO   A dg argument must be used. Use -o for a do-nothing argument.
  59. ECHO   e.g. " dgw -o  searchterm *.txt " 
  60. :paterror
  61. ECHO   The output of each search is written to file "ztempx"
  62. ECHO   Be sure that the wildcard term cannot "see" the file tempx
  63. ECHO   NAME.* or *.NAM is ok. But be in a separate directory to use * or *.*
  64. ECHO   e.g., NOT "dgw -o  searchterm *.*" NOR "dgw -o  searchterm *"
  65. ECHO   e.g., BUT "dgw -o  searchterm subdir/*.*" will work.
  66. :end
  67.  
  68.